<template>
	<view class="app content">
		<view class="cell" style="display: flex;justify-content: space-between;">
			<text class="tit fill">选择密保</text>
			<text class="" style="color:#999;font-size:30rpx;float: right;">
				<picker :range="list" @change="changeValue">
					<view>{{key?key:"请选择密保"}}</view>
				</picker>
			</text>
			<!-- <input class="input" v-model="oldpwd" type="password" maxlength="16" placeholder="请输入原密码" placeholder-style="color:#999;font-size:30rpx" /> -->
		</view>
		<view class="cell">
			<text class="tit fill">答案</text>
			<input class="input" v-model="value" type="text" maxlength="16" placeholder="请输入答案" placeholder-style="color:#999;font-size:30rpx" />
		</view>
		<button class="add-btn" @click="confirm('add')">提交</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				showPwd: false,
				oldpwd: '',
				pwd: '',
				repwd: '',
				list:[],
				key:"",
				value:""
			}
		},
		onLoad() {
			this.$fun.ajax.post('config/gettitle',{}).then(res=>{
				this.list = res.data
			})
		},
		methods: {
			changeValue(e){
				this.key = this.list[e.detail.value]
			},
			async confirm() {
				let {
					key,
					value,
				} = this;
				let parms = {
					key,
					value,
				}
				if (key == '') {
					this.$fun.msg('请选择密保')
					return
				}
				if (value == '') {
					this.$fun.msg('请输入答案')
					return
				}
				await this.$fun.ajax.post('user/mibao',{ ...parms
				}).then(res => {
					//console.log(res)
					if (res.code == 1) {
						this.$fun.msg(res.msg)
						setTimeout(()=>{
							uni.navigateBack({
							
							})
						},1000)
					}
				})
			},
			changePwdState() {
				this.showPwd = !this.showPwd;
			}
		}
	}
</script>

<style scoped lang="scss">
	.app {
		padding-top: 30rpx;
	}
	.add-btn{
		position: fixed;
		    left: 15px;
		    right: 15px;
		    bottom: 8px;
		    z-index: 95;
		    display: flex;
		    align-items: center;
		    justify-content: center;
		    width: 345px;
		    height: 40px;
		    font-size: 16px;
		    color: #fff;
		    background-color: #5990FF;
		    border-radius: 5px;
		    // box-shadow: 1px 2px 5px rgb(219 63 96 / 40%);
	}
	.cell {
		display: flex;
		align-items: center;
		min-height: 110rpx;
		margin: 0 40rpx;
		border-bottom: 1px solid rgb(236, 236, 236);

		&:first-child {
			margin-bottom: 10rpx;
		}

		&:after {
			left: 40rpx;
			right: 40rpx;
			border-color: #d8d8d8;
		}

		.tit {
			font-size: 30rpx;
			color: #333;
		}

		.avatar-wrap {
			width: 120rpx;
			height: 120rpx;
			position: relative;
			border-radius: 100rpx;
			overflow: hidden;

			.avatar {
				width: 100%;
				height: 100%;
				border-radius: 100rpx;
			}

			.progress {
				position: absolute;
				left: 50%;
				top: 50%;
				transform: translate(-50%, -50%);
				width: 100rpx;
				height: 100rpx;
				box-shadow: rgba(0, 0, 0, .6) 0px 0px 0px 2005px;
				border-radius: 100rpx;
				transition: .5s;
				opacity: 0;

				&.no-transtion {
					transition: 0s;
				}

				&.show {
					opacity: 1;
				}
			}
		}

		.input {
			flex: 1;
			text-align: right;
			font-size: 28rpx;
			color: #333;
		}

		switch {
			margin: 0;
			transform: scale(0.8) translateX(10rpx);
			transform-origin: center right;
		}

		.tip {
			margin-left: 20rpx;
			font-size: 28rpx;
			color: #999;
		}

		.checkbox {
			padding: 12rpx 0 12rpx 40rpx;
			font-size: 28rpx;
			color: #333;

			.mix-icon {
				margin-right: 12rpx;
				font-size: 36rpx;
				color: #ccc;
			}
			.icon-xuanzhong {
				color: $base-color;
			}
		}
	}
</style>
